<template>
  <el-container>
    <el-aside width="226px">
      <!-- logo -->
      <div class="logo"></div>
      <!-- 导航菜单 -->
      <Menu />
    </el-aside>
    <el-container>
      <el-header>
        <el-dropdown @command="handleCommand">
          <span class="el-dropdown-link">
            {{ adminInfo.username
            }}<i class="el-icon-arrow-down el-icon--right"></i>
          </span>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item command="logout" @click="logout"
              >安全退出</el-dropdown-item
            >
          </el-dropdown-menu>
        </el-dropdown>
      </el-header>
      <el-main>
        <!-- 二级路由占位符 -->
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
// 导入导航菜单组件
import Menu from "../components/Menu";
// 导入工具函数
import { getLoginInfo } from "../utlis/common";
export default {
  components: { Menu },
  methods: {
    // command事件处理函数
    handleCommand(command) {
      this[command]();
    },
    logout() {
      // 1-移除本地存储中的登录信息
      localStorage.removeItem("adminInfo");
      // 2-自动跳转到登录页面
      this.$router.push("/login");
      // 3-成功提示信息
      // this.$message({type:'',message:''});
      this.$message.success("退出成功");
    },
  },
  data() {
    return {
      // 登录账号信息
      adminInfo: {},
    };
  },
  created() {
    this.adminInfo = getLoginInfo();
  },
};
</script>

<style scoped>
@import "../assets/css/common.css";
.el-container {
  height: 100vh;
}
.logo {
  width: 200px;
  height: 60px;
  margin: auto;
  background: url("../assets/imgs/logo-white.png") no-repeat center center;
  background-size: 70%;
}
.el-header {
  background-color: #fff;
  color: #333;
  line-height: 60px;
  display: flex;
  justify-content: flex-end;
}

.el-aside {
  background-color: #ff674b;
  color: #fff;
}

.el-main {
  background-color: #e9eef3;
  color: #333;
}

.el-menu {
  border-right: 0 !important;
}
</style>